
package com.insigma.business.qrcode.common.converter;

import com.insigma.business.qrcode.intell.dto.CareSoldierDemandBSearcher;
import com.insigma.business.qrcode.intell.dto.CareSoldierDemandInsertRequest;
import com.insigma.business.qrcode.intell.entity.CareSoldierDemandDO;
import com.insigma.business.qrcode.soldier.dto.CareSoldierDemandDTO;
import com.insigma.business.qrcode.soldier.request.CareSoldierDemandSearchRequest;
import org.springframework.beans.BeanUtils;

import java.util.List;


public class CareSoldierDemandProviderConverter extends AbstractConverter<CareSoldierDemandDTO, CareSoldierDemandDO> {

    private final static CareSoldierDemandProviderConverter careSoldierDemandConverter = new CareSoldierDemandProviderConverter();

    private CareSoldierDemandProviderConverter(){}

    


    
    public static CareSoldierDemandDO convertRequestIO2DO(final CareSoldierDemandInsertRequest careSoldierDemandInsertRequest) {
        final CareSoldierDemandDO careSoldierDemandDO = new CareSoldierDemandDO();
        BeanUtils.copyProperties(careSoldierDemandInsertRequest,careSoldierDemandDO);
        return careSoldierDemandDO;
    }

    
    public static List<CareSoldierDemandDTO> convertResponseDOList2DTOList(final List<CareSoldierDemandDO> careSoldierDemandDOList){
        return careSoldierDemandConverter.convertGenericResponseDOList2DTOList(careSoldierDemandDOList);
    }

    public static CareSoldierDemandBSearcher convertRequestSO2Searcher(final CareSoldierDemandSearchRequest request){
        final CareSoldierDemandBSearcher careSoldierDemandBSearcher = new CareSoldierDemandBSearcher(request.getPageNo(),
                request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,careSoldierDemandBSearcher);
        return careSoldierDemandBSearcher;
    }
    public static CareSoldierDemandDTO convertResponseDO2DTO(final CareSoldierDemandDO careSoldierDemandDO){
        return careSoldierDemandConverter.convertGenericResponseDO2DTO(careSoldierDemandDO);
    }

    
    @Override
    protected CareSoldierDemandDTO doConvertResponseDO2DTO(CareSoldierDemandDO careSoldierDemandDO) {
        final CareSoldierDemandDTO careSoldierDemandDTO = new CareSoldierDemandDTO();
        try {
            BeanUtils.copyProperties(careSoldierDemandDO, careSoldierDemandDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return careSoldierDemandDTO;
    }

}
